namespace ConcurrentBoo.Tests

import System
import System.Threading
import NUnit.Framework from nunit.framework
import ConcurrentBoo

[TestFixture]
class PrimitivesTestFixture:
	
	public static final SleepPeriod = 100ms
	
	[Test]
	def ReadingComputationValueBlocks():
		processed = false		
		c = asynchronously() do:
			Thread.Sleep(SleepPeriod)
			processed = true
		assert c.Value is Computation.Nothing
		assert processed
		
	[Test]
	def ExceptionsAreRecordedAndReplayed():
		x = ApplicationException("ouch")
		c = asynchronously() do:
			raise x 
		assert c.Failure is x
		try:
			print c.Value
			Assert.Fail("Expecting: " + ComputationFailureException)
		except f as ComputationFailureException:
			assert f.InnerException is x
		

